
/**
 * Write a description of class CREEP here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
import java.awt.*;
import java.util.Timer;
import java.util.TimerTask;
public abstract class CREEP
{
    protected int xPos;
    protected int yPos;
    protected int speed;
    protected int health;
    protected int fullhealth;
    protected int nextWaypoint;
    protected int speedbuffer;
    protected int backupspeedbuffer;
    protected boolean frozen = false;
    protected int reward;
    
    
    public CREEP(int xPos_p, int yPos_p, int speed_p, int health_p)
    {
        xPos = xPos_p;
        yPos = yPos_p;
        speed = speed_p;
        health = health_p;
        fullhealth = health_p;
        nextWaypoint = 1;
        backupspeedbuffer = speed_p;
    }
    
    public abstract void paint(Graphics g);
    
    public void freeze(double factor)
    {
        frozen = true;
        speedbuffer = speed;
        speed/=factor;
    }
    
    public int getGold()
    {
        return reward;
    }
    
    public void unfreeze()
    {
        frozen = false;
        speed = backupspeedbuffer;
    }
    
    public boolean getfrozen()
    {
        return frozen;
    }
    
    public void addDamage(int damage)
    {
        if(damage>health) MAIN.sendMessage("creepdefeat",(CREEP)this);
        health -= damage;
    }
    
    public String getInformation(String what)
    {
        if(what.equals("health"))
        {
            return ""+health;
        }
        if(what.equals("death"))
        {
            return (health>0)?"false":"true";
        }
        
        return "";
    }
    
    public int getxPos()
    {
        return xPos;
    }
    
    public void setxPos(int xPos_p)
    {
        xPos = xPos_p;
    }
    
    public int getyPos()
    {
        return yPos;
    }
    
    public void setyPos(int yPos_p)
    {
        yPos = yPos_p;
    }
    
    public int getspeed()
    {
        return speed;
    }
    
    public int getnextWaypoint()
    {
        return nextWaypoint;
    }
    
    public void setnextWaypoint(int nextWaypoint_p)
    {
        nextWaypoint = nextWaypoint_p;
    }
    public boolean freezeable()
    {
        return true;
    }
    public String toString()
    {
        return xPos+" "+yPos;
    }
}
